package com.test.fundible.fundible_04_home;

import android.annotation.SuppressLint;
import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.ViewGroup;

import androidx.annotation.NonNull;

import com.test.fundible.R;
import com.test.fundible.fundible_00_http.OkHttpUtil;


public class Proce_fundiblessDialog extends Dialog {

    private final String pa_fundiblege;
    private final Runnable applyRunn_fundibleable;

    public Proce_fundiblessDialog(@NonNull Context context, String page, Runnable applyRunnable) {
        super(context);
        this.pa_fundiblege = page;
        this.applyRunn_fundibleable = applyRunnable;
    }

    @SuppressLint("ClickableViewAccessibility")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.dialog_fundible_process);
        getWindow().setBackgroundDrawableResource(R.color.transparent);
        getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);

        findViewById(R.id.dfp_view_out).setOnClickListener(v -> dismiss());
        findViewById(R.id.dfp_view_in).setOnTouchListener((v, event) -> true);

        findViewById(R.id.dfp_btn_apply).setOnClickListener(v -> {

            OkHttpUtil.getInstance_fundible().uploadEventPoint(pa_fundiblege,"APPLY_CLICK","");
            dismiss();
            if (applyRunn_fundibleable !=null) applyRunn_fundibleable.run();
        });
    }


}
